{% set title = 'Isolate global config' %}
{% extends "isolate/base.html" %}

{% block body %}
<h1>Server global config</h1>

Last updated by:
<strong>{% if cfg.updated_by %}{{cfg.updated_by.to_bytes()}}{% else%}N/A{%endif%}
  </strong>.<br>
Last updated on: <strong>{{cfg.updated_ts|datetimeformat}}</strong>.<br>

{% if note %}
<span style="color: red; font-style: italic">{{note}}</span><p>
{% endif %}

<form method="post" action="{{path}}">
  <h2>General</h2>
  Google Analytics ID:
  <input name="google_analytics" value="{{cfg.google_analytics}}"/><br>

  <h2>Cache</h2>
  <div>
    Default expiration (secs):<br />
    <input type="text" name="default_expiration"
        value="{{cfg.default_expiration}}" size="60" />
  </div>
  <h2>Google storage</h2>
  See this <a href="https://developers.google.com/storage/docs/accesscontrol#About-the-Client-ID">
  page</a> for instructions on how to setup Service account for API Access to
  Google Storage.
  <p>
  <div>
    Google Storage Bucket:<br />
    <input type="text" name="gs_bucket" value="{{cfg.gs_bucket}}" size="60" />
  </div>
  <br>
  <div>
    API access client email address:<br />
    <input type="text" name="gs_client_id_email"
        value="{{cfg.gs_client_id_email}}" size="60" />
  </div>
  <br>
  <div>
    API access base64 encoded *.der private key:<br />
    <textarea rows="14" cols="80"
        name="gs_private_key">{{cfg.gs_private_key}}</textarea>
  </div>
  <br>
  <input type="hidden" name="keyid" value="{{cfg.key.integer_id()}}" />
  <input type="hidden" name="xsrf_token" value="{{xsrf_token}}" />
  <input type="submit" value="Submit" />
</form>
<br>

<hr>

<p>To convert secret.p12 key generated by API Console into base64 encoded
*.der key use this script:
<pre>
  # Convert *.p12 to *.pem. Use password 'notasecret'.
  openssl pkcs12 -in secret.p12 -nodes -nocerts > secret.pem
  # Convert *.pem into *.der.
  openssl rsa -in secret.pem -inform PEM -out secret.der -outform DER
  # Base64 encode *.der and copy-paste it into the form above.
  cat secret.der | base64
  # Remove temp files.
  rm secret.der secret.pem
</pre>
</p>

{% endblock %}
